Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
ansi-colors
Advanced tools
The ansi-colors npm package is a utility for styling strings in the terminal with ANSI escape codes. It allows developers to add color and style to text output in command-line applications.
Text Colors
Apply text color to strings. The example shows how to make text red.
"const colors = require('ansi-colors');\nconsole.log(colors.red('This is red text'));"
Background Colors
Apply background color to strings. The example shows how to give text a red background.
"const colors = require('ansi-colors');\nconsole.log(colors.bgRed('This has a red background'));"
Text Styles
Apply text styles like bold, italic, underline, etc. The example shows how to make text bold.
"const colors = require('ansi-colors');\nconsole.log(colors.bold('This is bold text'));"
Chaining Styles
Chain multiple styles together. The example shows text that is blue, bold, and underlined.
"const colors = require('ansi-colors');\nconsole.log(colors.blue.bold.underline('This is blue, bold, and underlined'));"
Custom Themes
Create custom themes by combining styles. The example defines a custom theme with styles for error and warning messages.
"const colors = require('ansi-colors');\nconst customTheme = {\n error: colors.red.bold,\n warning: colors.yellow.italic\n};\nconsole.log(customTheme.error('Error message'));\nconsole.log(customTheme.warning('Warning message'));"
Chalk is a popular package similar to ansi-colors that provides a chainable API for styling strings. It offers a more extensive API and additional features like template literal support.
Kleur is a lightweight alternative to ansi-colors, focusing on performance. It has a similar API but does not support older versions of Node.js.
Colorette is another lightweight package for coloring terminal text. It aims to be fast and simple, with a minimalistic API compared to ansi-colors.
Collection of ansi colors and styles.
Install with npm:
$ npm install --save ansi-colors
This module exports an object of functions. Each function wraps a string with the ansi codes used to display the string with that color (or style). Use the wrapped string with console.log
:
var colors = require('ansi-colors');
console.log(colors.bold(colors.cyan('[info]')), colors.cyan('This is some information'));
console.log(colors.bold(colors.yellow('[warning]')), colors.yellow('This is a warning'));
console.error(colors.bold(colors.red('[ERROR]')), colors.red('Danger! There was an error!'));
See the example for more colors and styles.
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Commits | Contributor |
---|---|
10 | doowb |
3 | jonschlinkert |
(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)
To generate the readme, run the following command:
$ npm install -g verbose/verb#dev verb-generate-readme && verb
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
$ npm install && npm test
Brian Woodward
Copyright © 2018, Brian Woodward. Released under the MIT License.
This file was generated by verb-generate-readme, v0.6.0, on January 12, 2018.
FAQs
Easily add ANSI colors to your text and symbols in the terminal. A faster drop-in replacement for chalk, kleur and turbocolor (without the dependencies and rendering bugs).
The npm package ansi-colors receives a total of 13,619,207 weekly downloads. As such, ansi-colors popularity was classified as popular.
We found that ansi-colors demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.